package gui;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.EventQueue;

import javax.swing.BorderFactory;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;
import javax.swing.border.EmptyBorder;
import javax.swing.border.TitledBorder;
import javax.swing.JButton;

import ch.randelshofer.quaqua.QuaquaLookAndFeel;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;

public class InterpolatorChooser extends JFrame {
	public static InterpolatorChooser p2v = new InterpolatorChooser();
	private JPanel contentPane;

	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					InterpolatorChooser frame = new InterpolatorChooser();
					frame.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}

	/**
	 * Create the frame.
	 */
	public InterpolatorChooser() {
		setUndecorated(true);
		setBounds(100, 100, 199, 236);
		contentPane = new JPanel();
		contentPane.setBorder(new TitledBorder(null, "Numerical Beast", TitledBorder.CENTER, TitledBorder.ABOVE_TOP, null, null));
		contentPane.setBackground(Color.lightGray);

		setContentPane(contentPane);
		contentPane.setLayout(null);
		
		try {
			UIManager.setLookAndFeel(new QuaquaLookAndFeel());
		} catch (UnsupportedLookAndFeelException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		JButton button = new JButton("General Algorihm");
		button.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				setVisible(false);
				 Interpolator.gui = new Interpolator("");
				 Interpolator.gui.setVisible(true);
				 Main.main.setVisible(false);
			}
		});
		button.setBounds(10, 40, 169, 46);
		contentPane.add(button);
		
		JButton btnLagrangeInterpolation = new JButton("Lagrange interpolation");
		btnLagrangeInterpolation.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				setVisible(false);
				Interpolator.gui = new Interpolator("l");
				Interpolator.gui.setVisible(true);
				 Main.main.setVisible(false);
			}
		});
		btnLagrangeInterpolation.setBounds(10, 97, 169, 46);
		contentPane.add(btnLagrangeInterpolation);
		
		JButton btnDividedDifference = new JButton("Divided difference");
		btnDividedDifference.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				setVisible(false);
				Interpolator x = new Interpolator("d");
				x.setVisible(true);
				 Main.main.setVisible(false);
			}
		});
		btnDividedDifference.setBounds(10, 165, 169, 46);
		contentPane.add(btnDividedDifference);
	}

}
